package com.domain.adapter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * ClassName: AhsWebMvcConfigurerAdapter<br>
 * Description: 访问拦截器 拦截指定的请求.<br>
 *
 * @author Sean
 * @version V1.0
 * @date: 2016年11月16日 下午5:07:19
 * @since JDK 1.8
 */
@Configuration
public class WebAdapter extends WebMvcConfigurerAdapter {


    /**
     * 访问拦截器 拦截指定的请求<br>
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 拦截以及跨域授权
        // 拦截授权请求

        registry.addInterceptor(new AuthorizationHandlerInterceptor()).addPathPatterns("/auth/**")
                .excludePathPatterns("/**/exc/**");
        // 拦截签名请求
        registry.addInterceptor(new SignatureHandlerInterceptor()).addPathPatterns("/sign/**");
        // 拦截开放出去的请求
        registry.addInterceptor(new ExternalHandlerInterceptor()).addPathPatterns("/exte/**");
        super.addInterceptors(registry);
    }
}
